package com.hhit.collaborative_learning.learning;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class ClearSessionServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession();
		session.removeAttribute("cl_userInfo");

		Cookie[] cookies = request.getCookies();
		for (Cookie c : cookies) {
			if (c.getName().equals("userId") || c.getName().equals("digged")
					|| c.getName().equals("userIcon")|| c.getName().equals("uRight")
					|| c.getName().equals("userNickName")||c.getName().equals("cl_blogRight")||c.getName().equals("q_digged")||c.getName().equals("qa_digged")) {
				c.setMaxAge(0);
				c.setPath("/");
				response.addCookie(c);
			}
		}
		// session.removeAttribute("twoDays");
		// session.removeAttribute("newestRec");
		// session.removeAttribute("experts");
		// session.removeAttribute("newestExpert");
		// session.removeAttribute("primeBlog");
		// StoreData.newestExperts.clear();
		// StoreData.newestRecommendBlog.clear();
		// StoreData.primeBlog.clear();
		// StoreData.twoDaysBlog.clear();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

}
